<template>
	<el-drawer :title="`人员考核详情【`+userInfo.userName+`】`" v-model="visible" :size="800" destroy-on-close @closed="$emit('closed')">
		<el-container v-loading="loading">
			<el-main>
				<el-form>
					<el-main class="nopadding" style="font-size: 16px">
						<div v-for="(item,index) in itemList" :key="index" style="margin: 15px">
							<div>
								{{ index + 1 }}、{{ item.title }}
							</div>
							<el-radio-group v-if="item.optType=='0'" v-model="itemList[index].selected" :disabled="true">
								<el-radio v-for="(childItem,i) in item.childItem" :label="childItem.childId" :key="i">{{ childItem.childTitle }}/{{childItem.childScore}}分</el-radio>
							</el-radio-group>
							<el-checkbox-group v-if="item.optType=='1'" v-model="itemList[index].selected" :disabled="true">
								<el-checkbox v-for="(childItem,i) in item.childItem" :label="childItem.childId" :key="i">{{ childItem.childTitle }}/{{childItem.childScore}}分</el-checkbox>
							</el-checkbox-group>
						</div>
						<el-form-item label="考核成绩">
							<el-tag type="success">{{ score }}/分</el-tag>
						</el-form-item>
					</el-main>
				</el-form>
				<el-footer style="text-align: center;">
					<el-button @click="visible=false">关闭</el-button>
				</el-footer>
			</el-main>
		</el-container>
	</el-drawer>
</template>

<script>
import AttachMenu from '@/views/module/attachMenu'
export default {
	emits: ['success', 'closed'],
	components: {
		AttachMenu,
	},
	data() {
		return {
			loading: false,
			itemList:[],
			resItemList:[],
			visible: false,
			isSaveing: false,
			score:0,
			userInfo:{},
			form:{
				planId:"",
				accountId:""
			}
		}
	},
	mounted() {

	},
	methods: {
		open(model){
			this.model=model;
			this.visible = true;
			return this;
		},
		//表单注入数据
		setData(data){
			this.form.planId = data.planId;
			this.form.accountId = data.accountId;
			this.getHrKpiRecordForDetails();
		},
		async getHrKpiRecordForDetails(){
			let res = await this.$API.hr.hrKpiPlan.getHrKpiRecordForDetails.get(this.form);
			if (res.code == 200) {
				this.userInfo = res.data.userInfo;
				this.score = res.data.hrKpiPlanRecord.score;
				this.resItemList = JSON.parse(res.data.hrKpiPlanRecord.comment);
				this.itemList = JSON.parse(res.data.hrKpiItem.itemJson);
				this.resItemList.forEach(item=>{
					this.itemList.forEach(tempItem=>{
						if(tempItem.itemId == item.itemId)
						{
							tempItem.selected = item.selected;
						}
					})
				})
			} else {
				this.$alert(res.message, "提示", {type: 'error'})
			}
		}
	}
}
</script>

<style>
</style>
